var app=getApp();
var startPoint;
 Page({
   data: {
    animationData:{},
    cainiaoRight:0,
    cainiaoTop:750,
    province:"",
    movies:[  
            {url:'../../image/img1.jpg'} ,  
            {url:'../../image/img2.jpg'} ,  
            {url:'../../image/img3.jpg'} ,  
    ],
    firstType:'实习',
    selectType:true,
    list:[
      {name:"技术"},
      {name:"产品"},
      {name:"运营"},
      {name:"设计"}
    ],
    post1:true,
    post2:false,
    post3:false,
    post4:false,
    technology:[], 
    technologyIntership:[],
    technologySchool:[],
    technologySociety:[],
    product: [],
    operation: [],
    design: [],
  },
  onLoad: function (options){
    var that=this;
    var pro = app.globalData.provinceSelected;
    if (pro==""||pro=="全国"){
      that.setData({
        province: "全国"
      }) 
    }
    else{
      that.setData({
        province:pro
      }) 
    }
    wx.request({
      url:'http://106.15.201.147/wx_admin/jobs/jobList',
      method:'post',
      header:{
        'Content-Type':'application/json'
      },
      data:{
        type:'实习',
        category:'0'
      },
      success:function(res){
        that.setData({
          technology: res.data,
          technologyIntership:res.data,
        })
        console.log(that.data.technology)
      } 
    });
    wx.request({
      url: 'http://106.15.201.147/wx_admin/jobs/jobList',
      method: 'post',
      header: {
        'Content-Type': 'application/json'
      },
      data: {
        type: '社招',
        category: '0'
      },
      success: function (res) {
        that.setData({
          technologySociety: res.data,
        })
      }
    });
    wx.request({
      url: 'http://106.15.201.147/wx_admin/jobs/jobList',
      method: 'post',
      header: {
        'Content-Type': 'application/json'
      },
      data: {
        type: '校招',
        category: '0'
      },
      success: function (res) {
        that.setData({
          technologySchool: res.data,
        })
      }
    });
    wx.request({
      url: 'http://106.15.201.147/wx_admin/jobs/jobList',
      method: 'post',
      header: {
        'Content-Type': 'application/json'
      },
      data: {
        type: '实习',
        category: '1'
      },
      success: function (res) {
        that.setData({
          product: res.data,
        })
      }
    });
    wx.request({
      url: 'http://106.15.201.147/wx_admin/jobs/jobList',
      method: 'post',
      header: {
        'Content-Type': 'application/json'
      },
      data: {
        type: '实习',
        category: '2'
      },
      success: function (res) {
        that.setData({
          operation: res.data,
        })
      }
    });
    wx.request({
      url: 'http://106.15.201.147/wx_admin/jobs/jobList',
      method: 'post',
      header: {
        'Content-Type': 'application/json'
      },
      data: {
        type: '实习',
        category: '3'
      },
      success: function (res) {
        that.setData({
          design: res.data,
        })
      }
    })
  },
  clickIntership:function(){
     this.data.technology=this.data.technologyIntership
  },
  clickSchool: function () {

  },
  clickSociety: function () {

  },
  postChoose1:function(){
    this.setData({
      post1:true,
      post2:false,
      post3: false,
      post4: false
    })
  },
  postChoose2:function(){
    this.setData({
      post1: false,
      post2: true,
      post3: false,
      post4: false
    })
  },
  postChoose3: function () {
    this.setData({
      post1: false,
      post2: false,
      post3: true,
      post4: false
    })
  },
  postChoose4: function () {
    this.setData({
      post1: false,
      post2: false,
      post3: false,
      post4: true
    })
  },
  clicktype:function(){
    var selectType=this.data.selectType;
    if(selectType==true){
      this.setData({
        selectType:false
      })
    }else{
      this.setData({
        selectType:true
      })
    }
   },
   mySelect:function(e){
    this.setData({
      firstType:e.target.dataset.me,
      selectType:true,
    })
    if(this.data.firstType=='实习'){
      this.setData({
        technology: this.data.technologyIntership
      })
    }
    if (this.data.firstType == '校招') {
      this.setData({
        technology: this.data.technologySchool
      })
    }
    if (this.data.firstType == '社招') {
      this.setData({
        technology: this.data.technologySociety
      })
    }
   },
   cainiaoStart: function (e) {
     startPoint = e.touches[0]
   },
   cainiaoMove: function (e) {
     var endPoint = e.touches[e.touches.length-1]
     var translateX = startPoint.clientX-endPoint.clientX
     var translateY = endPoint.clientY-startPoint.clientY
     startPoint = endPoint
     var cainiaoTop = this.data.cainiaoTop + translateY
     var cainiaoRight = this.data.cainiaoRight + translateX
     this.setData({
       cainiaoTop:cainiaoTop,
       cainiaoRight:cainiaoRight
     })
     if(cainiaoRight<0){
       this.setData({
         cainiaoRight:0
       })
     }
     if (cainiaoRight>=650) {
       this.setData({
         cainiaoRight: 650
       })
     }
     if (cainiaoTop<0) {
       this.setData({
         cainiaoTop: 0
       })
     }
   },
  cainiaoEnd: function (e) {
  },
  jobDetail:function(e){
    var that=this;
    var postId=e.currentTarget.dataset.postid;
    wx.navigateTo({
      url: '../jobDetail/jobDetail?id='+JSON.stringify(postId)
    })
  },
  switchProvince:function(){
    wx.navigateTo({
      url: '../switchProvince/switchProvince',
    })
  }
})
